package org.catspaw.cherubim.persistence.jpa;

import javax.persistence.EntityManager;

import org.catspaw.cherubim.persistence.ResourceCallback;

public class ThreadLocalEntityManagerMaster implements EntityManagerMaster {

	public <T> T execute(ResourceCallback<EntityManager, T> callback) {
		EntityManager em = getResource();
		return callback.doInResource(em);
	}

	public EntityManager getResource() {
		return EntityManagerFactoryUtils.getCurrentEntityManager();
	}
}
